package com.dlc.shop.systemtest.api.amount;

import com.dlc.shop.common.util.PageParam;
import com.dlc.shop.distribution.common.dto.StatisticsDisUserIncomeDto;
import com.dlc.shop.distribution.common.model.DistributionUserIncome;
import com.dlc.shop.distribution.common.param.RangeTimeParam;
import com.dlc.shop.distribution.common.vo.DistributionOrdersVO;
import com.dlc.shop.systemtest.constants.Constant;
import com.dlc.shop.systemtest.util.HttpUtil;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Objects;

/**
 * 分销员收入接口
 * @author: zsm
 * @date: 2023/2/28 9:15
 */
public class DistributionUserIncomeApi {


    /**
     * 通过状态获取我的推广订单(0:待支付 1:待结算 2:已结算 -1:订单失效)"
     * @param page
     * @param state
     * @return
     */
    public static void getMyPromotionOrderByState(PageParam<DistributionOrdersVO> page,
                                                                          @RequestParam(value = "state", required = false) Integer state) {
        String url = Constant.API_URL + "/p/distribution/income/myPromotionOrder"+  "?current=" + page.getCurrent() +"&size=" + page.getSize() + "&state=" + state;
        HttpUtil.get(url);
    }

    /**
     * 分页获取收益列表
     * @param page
     * @return
     */
    public static void getDistributionUserIncomePage(PageParam<DistributionUserIncome> page) {
        String url = Constant.API_URL + "/p/distribution/income/page";
        HttpUtil.get(url);
    }

    public static String getPlatformPage(PageParam<DistributionUserIncome> page,
                                         RangeTimeParam rangeTimeParam, String userMobile, String orderNumber,
                                         Integer state, DistributionUserIncome distributionUserIncome) {
        String url = "";
        if(Objects.nonNull(state)){
            url = Constant.PLATFORM_URL + "/distribution/distributionUserIncome/page/anduser?orderNumber=" + orderNumber + "&state=" + state + "&userMobile=" + userMobile;
        }else{
            url = Constant.PLATFORM_URL + "/distribution/distributionUserIncome/page/anduser?orderNumber=" + orderNumber  + "&userMobile=" + userMobile;
        }

        return HttpUtil.get(url, String.class);
    }

    /**
     * 统计分销员今日、本月的收益
     * @return
     */
    public static StatisticsDisUserIncomeDto statisticsDistributionUserIncome(){
        String url = Constant.API_URL + "/p/distribution/income/statistics";
        return HttpUtil.get(url, StatisticsDisUserIncomeDto.class);
    }

}

